--  ---------------------------------------------------------------------------
--  @File: errors.adb
--
--  @Project: LiberAda
--  @Version: 1.0
--  @Created: 2009-09-23
--  @Author:  Markus Knauß, Julian Trischler
--
--  @Description:
--    For a detailed description of this package (@see errors.ads).
--  @Implementation:
--    Handling with error messages is realized here.
--
--  @Modifications:
--    +2011-04-23 JT: Corrected termination with failure exit code and printing
--      error message to StdErr instead of StdOut.
--    +2009-09-23 MK: Initial release
--
--  ---------------------------------------------------------------------------
with Ada.Text_IO;
with Ada.Command_Line;
with Messages;

package body Errors is

   --  ------------------------------------------------------------------------
   --  @Procedure: Print_Error
   procedure Print_Error (Key : in String) is
   begin
      Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error, "Error: "
                            & Messages.Get_Message (Key));
      Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
   end Print_Error;

begin
   Messages.Add_Message ("VALUES_FOR_EXTENSIONS_PARAMETER_MISSING",
                         "No values given for extension parameter.");
   Messages.Add_Message ("INCLUDE_PARAMETER_MISSING",
                         "Files and directories to include are not" &
                         " specified.");
   Messages.Add_Message ("VALUES_FOR_INCLUDE_PARAMETER_MISSING",
                         "Files and directories to include" &
                         " are not specified.");
   Messages.Add_Message ("OUTPUT_LOCATION_IS_NO_DIRECTORY",
                         "Given location for output is no directory.");
   Messages.Add_Message ("MULTIPLE_OUTPUT_LOCATIONS",
                         "Only one location for output is allowed.");
   Messages.Add_Message ("OUTPUT_LOCATION_VALUE_MISSING",
                         "Value for -o parameter is missing.");
   Messages.Add_Message ("OPENING_SOURCE_FILE_FAILED",
                         "Opening source file failed.");
   Messages.Add_Message ("NO_SOURCE_FILES",
                         "No source files to read from.");

end Errors;
